define([
    'jquery',
    'underscore',
    'backbone',
    'views/message/thread-item',
    'iscroll'
], function ($, _, Backbone, ThreadMessageListItemView) {
    var ThreadMessageListView = Backbone.View.extend({

        tagName:'ul',

        initialize:function () {
            /*this.model.bind("reset", this.render, this);
            var self = this;
            this.model.bind("add", function (message) {
                $(self.el).prepend(new ThreadMessageListItemView({model:message}).render().el);
            });*/
        },

        render:function (eventName) {
            _.each(this.model.models, function (message) {
                $(this.el).attr('id', "list").addClass('nav nav-tabs nav-stacked').append(new ThreadMessageListItemView({model:message}).render().el);
            }, this);
            return this;
        },

        scrollRender:function(){
            //console.log('Rendering...');
            /* var scrollContent, scrollNav;

            var loaded =function() {
                console.log('loaded');
                scrollContent = new iScroll('contentWrapper');
                scrollNav = new iScroll('navWrapper');
            }

            document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);

            document.addEventListener('DOMContentLoaded', loaded, false);*/

            this.scrollNav = new iScroll('navWrapper');
            this.scrollContent = new iScroll('contentWrapper');
        }

    });
    return ThreadMessageListView;
});

